package bookSystem;

import bookSystem.book.BookList;
import bookSystem.user.AdminUser;
import bookSystem.user.NormalUser;
import bookSystem.user.User;


import java.util.Scanner;

public class Main {
    public static User login(){
        System.out.print("请输入你的名字：");
        Scanner scanner = new Scanner(System.in);
        String userName = scanner.nextLine();
        System.out.print("请输入你的账号：");
        String number = scanner.nextLine();
        System.out.print("请输入你的密码：");
        String password = scanner.nextLine();
        System.out.print("请选择你的身份：\n ->1管理员\n ->2普通用户\n");
        int rank = scanner.nextInt();
        if(rank == 1){
            //管理员
            return new AdminUser(userName);
        }else if(rank == 2){
            //普通用户
            return new NormalUser(userName);
        }else {
            return null;
        }
    }

    public static void main(String[] args) {
        //0、准备数据
        BookList bookList = new BookList();
        while (true) {
            //1、登录lu
            User user = login();
            //2、功能选择
            int choice = 0;
            while(choice != user.getIoPerations().length){
               choice = user.menu();
               user.doOperation(choice - 1, bookList);
            }
        }
    }
}
